package com.gt.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gt.app.domain.EsBookResult;
import com.gt.app.domain.EsColonScreeningBook;
import com.gt.app.domain.EsExpertTimeTable;
import com.gt.app.domain.vo.ColonScreeningBookVo;
import com.gt.app.mapper.EsColonScreeningBookMapper;
import com.gt.app.service.EsBookResultService;
import com.gt.app.service.EsColonScreeningBookService;
import com.gt.app.service.EsExpertTimeTableService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author caidesheng
 */
@Slf4j
@Service
public class EsColonScreeningBookServiceImpl extends ServiceImpl<EsColonScreeningBookMapper, EsColonScreeningBook> implements EsColonScreeningBookService {
    @Autowired
    private EsBookResultService esBookResultService;

    @Autowired
    private EsExpertTimeTableService esExpertTimeTableService;


    @Override
    public ColonScreeningBookVo getColonScreeningBook(String checkId) {
        ColonScreeningBookVo colonScreeningBookVo = new ColonScreeningBookVo();
        LambdaQueryWrapper<EsColonScreeningBook> bookWrapper = new LambdaQueryWrapper<EsColonScreeningBook>().eq(EsColonScreeningBook::getEsCheckId, checkId);
        EsColonScreeningBook book = this.getOne(bookWrapper);

        LambdaQueryWrapper<EsBookResult> resultWapper = new LambdaQueryWrapper<EsBookResult>().eq(EsBookResult::getEsCheckId, checkId);
        EsBookResult result = esBookResultService.getOne(resultWapper);

        List<EsExpertTimeTable> timeTables = esExpertTimeTableService.list();
        colonScreeningBookVo.setEsColonScreeningBook(book);
        colonScreeningBookVo.setEsBookResult(result);
        colonScreeningBookVo.setEsExpertTimeTable(timeTables);
        colonScreeningBookVo.setFlag("1");
        return colonScreeningBookVo;
    }
}
